﻿<%@ Page Title="d39 grid players" Language="C#" MasterPageFile="~/d39.Master" AutoEventWireup="true" CodeBehind="GridPlayers.aspx.cs" Inherits="d39.GridPlayers" %>

<asp:Content ContentPlaceHolderID="GridPaneContent" runat="server">
    <d39:GridManipulator runat="server" id="GridManipulator" />
</asp:Content>
<asp:Content ContentPlaceHolderID="ActionPaneContent" runat="server">
    <asp:UpdatePanel ID="UpdatePanel" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <div>
                <asp:LinkButton runat="server" ID="RollInitiative" OnClick="RollInitiative_Click" Text="Reroll Initiative" Visible='<%# InitiativeApplicable %>'/>
            </div>
            <div>
                <asp:CheckBox runat="server" ID="RevealUnknown" Checked='<%# CurrentGrid.RevealUnknown %>' OnCheckedChanged="RevealUnknown_CheckedChanged" Text="Show unknown players" AutoPostBack="true" Visible='<%# UnknownApplicable %>' />
            </div>
            <asp:ListView runat="server" ID="Players" ItemPlaceholderID="items">
                <LayoutTemplate><ul class="playerManip"><asp:PlaceHolder runat="server" ID="items" /></ul></LayoutTemplate>
                <ItemTemplate>
                    <li style='<%# "color: " + Eval("ColorString") + "; list-style-image: url(" + Eval("ImageUrl") + ")" %>' runat="server" visible='<%# CurrentGrid.RevealUnknown || !(bool)Eval("IsUnknown") %>'>
                        <div>
                            <%# Eval("Name") %><%# GetPositionsString(Container.DataItem) %>
                            <asp:LinkButton runat="server" ID="EditBtn" CommandName="Edit" Visible='<%# Players.EditIndex < 0 %>'>(Edit)</asp:LinkButton>
                            <asp:LinkButton runat="server" ID="DeleteBtn" CommandName="Delete" Visible='<%# Players.EditIndex < 0 %>'>(Delete)</asp:LinkButton>
                        </div>
                        <div>Description: <%# Eval("Description") %></div>
                        <div>Color: <%# Eval("ColorString") %></div>
                        <div>Size: <%# Eval("SizeName") %></div>
                        <div>Shape: <%# Eval("Shape.Name") %></div>
                        <div><%# Eval("InitiativeString") %></div>
                        <div>
                            <%# ((bool) Eval("IsFixed")) ? "Fixed" : "Movable" %>,
                            <%# ((bool) Eval("IsMulti")) ? "Multiple" : "Single" %>
                        </div>
                    </li>
                </ItemTemplate>
                <EditItemTemplate>
                    <li>
                        <div>
                            <asp:Label runat="server" AssociatedControlID="Name">Name:</asp:Label>
                            <asp:TextBox id="Name" runat="server" Columns="25" Text='<%# Bind("Name") %>' />
                        </div>
                        <div>
                            <asp:Label runat="server" AssociatedControlID="Description">Description:</asp:Label>
                            <asp:TextBox id="Description" runat="server" Columns="30" Text='<%# Bind("Description") %>' />
                        </div>
                        <div>
                            <asp:Label runat="server">Color:</asp:Label>
                            <d39:ColorPicker runat="server" ID="PlayerColor" Color='<%# Bind("Color") %>' />
                        </div>
                        <div>
                            <asp:Label runat="server" AssociatedControlID="PlayerSize">Size:</asp:Label>
                            <asp:DropDownList runat="server" ID="PlayerSize" SelectedValue='<%# Bind("Size") %>'
                                DataSource='<%# d39.Sizes.AllSizes %>' DataTextField="Value" DataValueField="Key"/>
                        </div>
                        <div>
                            <asp:Label runat="server" AssociatedControlID="PlayerShape">Shape:</asp:Label>
                            <asp:DropDownList runat="server" ID="PlayerShape" SelectedValue='<%# Bind("ShapeChar") %>'
                                DataSource='<%# d39.Shapes.AllShapes %>' DataTextField="Name" DataValueField="ShapeChar" />
                        </div>
                        <div>
                            <asp:Label runat="server" AssociatedControlID="InitiativeMod">Initiative:</asp:Label>
                            d20+<asp:TextBox runat="server" ID="InitiativeMod" Text='<%# Bind("InitiativeMod") %>' Columns="5" />
                            <asp:CompareValidator runat="server" ControlToValidate="InitiativeMod" Operator="DataTypeCheck" Type="Integer" Display="Dynamic" Text="Init mod must be a number" />
                        </div>
                        <div><asp:CheckBox runat="server" Text="Movable" Id="Movable" Checked='<%# Bind("IsMovable") %>' /></div>
                        <div><asp:CheckBox runat="server" Text="Multiple" Id="Multiple" Enabled='<%# ((int)Eval("Positions.Count")) <= 1 %>' Checked='<%# Bind("IsMulti") %>' /></div>
                        <div>
                            <asp:LinkButton runat="server" ID="UpdateBtn" CommandName="Update">(Update)</asp:LinkButton>
                            <asp:LinkButton runat="server" ID="CancelBtn" CommandName="Cancel">(Cancel)</asp:LinkButton>
                        </div>
                    </li>
                </EditItemTemplate>
            </asp:ListView>
            <div runat="server" visible='<%# Players.EditIndex < 0 %>'>
                <asp:LinkButton runat="server" ID="AddPlayerBtn">(Add Character/Item)</asp:LinkButton>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
